/**
 * 日志查询DTO
 * 作者：GodMainCode
 * 创建时间：2024-01-17
 * 修改时间：2024-01-17
 * 修改人：GodMainCode
 */

import { IsEnum, IsOptional, IsString, IsDateString, IsInt, Min } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import { LogType, LogLevel } from '../../../interfaces/log.interface';

export class QueryLogDto {
  @ApiProperty({ 
    description: '日志类型', 
    enum: LogType,
    required: false 
  })
  @IsEnum(LogType)
  @IsOptional()
  type?: LogType;

  @ApiProperty({ 
    description: '日志级别', 
    enum: LogLevel,
    required: false 
  })
  @IsEnum(LogLevel)
  @IsOptional()
  level?: LogLevel;

  @ApiProperty({ 
    description: '用户名', 
    required: false 
  })
  @IsString()
  @IsOptional()
  username?: string;

  @ApiProperty({ 
    description: 'IP地址', 
    required: false 
  })
  @IsString()
  @IsOptional()
  ip?: string;

  @ApiProperty({ 
    description: '开始时间', 
    required: false 
  })
  @IsDateString()
  @IsOptional()
  startTime?: Date;

  @ApiProperty({ 
    description: '结束时间', 
    required: false 
  })
  @IsDateString()
  @IsOptional()
  endTime?: Date;

  @ApiProperty({ 
    description: '页码', 
    minimum: 1,
    default: 1 
  })
  @IsInt()
  @Min(1)
  @IsOptional()
  page?: number = 1;

  @ApiProperty({ 
    description: '每页条数', 
    minimum: 1,
    maximum: 100,
    default: 10 
  })
  @IsInt()
  @Min(1)
  @IsOptional()
  pageSize?: number = 10;
} 